<%@ page language="java" errorPage="/framework/jsp/error.jsp"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page
	import="com.xwtech.cring.pub.dao.SysRoleDAO,com.xwtech.cring.pub.po.SysRole,com.xwtech.framework.pub.web.FrameworkApplication"%>
<%@include file="/framework/jsp/taglibs.jsp"%>
<%@ taglib prefix="xwcms" uri="/WEB-INF/CMSConfig/com.xwtech.cms.tld"%>
<link href="/cring/css/admin_style.css" rel="stylesheet" type="text/css">
<script src="/cring/js/ajax.js" type="text/javascript"></script>
<style>
<!--
.test {
	width: 200px;
}
-->
</style>
<script type="text/javascript">
function move_right() {
if (bindingUserForm.selectings.selectedIndex >= 0) {
bindingUserForm.selecteds.options.add(new Option(bindingUserForm.selectings.options[bindingUserForm.selectings.selectedIndex].text, bindingUserForm.selectings.options[bindingUserForm.selectings.selectedIndex].value));
bindingUserForm.selectings.options[bindingUserForm.selectings.selectedIndex].removeNode(true);
}
else { alert('请选择一个用户'); }
}

function move_left() {
if (bindingUserForm.selecteds.selectedIndex >= 0) {
bindingUserForm.selectings.options.add(new Option(bindingUserForm.selecteds.options[bindingUserForm.selecteds.selectedIndex].text, bindingUserForm.selecteds.options[bindingUserForm.selecteds.selectedIndex].value));
bindingUserForm.selecteds.options[bindingUserForm.selecteds.selectedIndex].removeNode(true);
}
else { alert('请选择一个用户'); }
}
function move(from,to) 
{
     var fromList = document.getElementById(from);
     var toList =document.getElementById(to);
    if (fromList.selectedIndex >= 0) 
    {
        for (i=0;i<fromList.options.length;i++)
       {
          var current = fromList.options[i];
          if (current.selected)
          {
             txt = current.text;
             val = current.value;
             toList.options[toList.length] = new Option(txt,val);
             fromList.options[i] = null;
             i--;
          }
       }
    }
    else 
    { 
        alert('请选择一个用户'); 
    }
}
/*全部右移*/
function move_right_all()
{
   for (var i=0; i<bindingUserForm.selectings.options.length; i++)
   {
      bindingUserForm.selecteds.options.add(new Option(bindingUserForm.selectings.options[i].text, bindingUserForm.selectings.options[i].value));
   }
   bindingUserForm.selectings.options.length = 0;
}
/*全部左移*/
function move_left_all() 
{
   for (var i=0; i<bindingUserForm.selecteds.options.length; i++)
   {
      bindingUserForm.selectings.options.add(new Option(bindingUserForm.selecteds.options[i].text, bindingUserForm.selecteds.options[i].value));
   }
   bindingUserForm.selecteds.options.length = 0;
}

function output_submit() {
var userlist = new Array();
for (var i=0; i<bindingUserForm.selecteds.options.length; i++) {
userlist[userlist.length] = bindingUserForm.selecteds.options[i].value;
bindingUserForm.selecteds.options[i].selected = true;
}
}
</script>
<%
	String groupId = request.getParameter("groupId");
	String sql = "select t2.user_info_id,user_name from frame_login t1, sys_user_info t2, sys_user_role t3,sys_role t4 where t4.role_id="
			+ groupId
			+ " and t1.login_id = t2.login_id and t2.user_info_id = t3.user_info_id and t3.role_id=t4.role_id order by user_name";
	SysRoleDAO sysRoleDAO = FrameworkApplication.cringDbCollection
			.getSysRoleDAO();
	SysRole sysRole = sysRoleDAO.getSysRole(Integer.valueOf(groupId));
%>

<form name="bindingUserForm" target="_parent"
	action="/cring/jsp/admin/bgUserManager.do?method=bindingUserAndUserGroup"
	onSubmit="return output_submit();" method="post"
	enctype="multipart/form-data" style="display: inline;">
	<input type="hidden" name="role_id" value="<%=groupId%>">
	<input type="hidden" name="_insert"
		value="/admin/bgUserRole_delete.xml,/admin/bgUserRole_insert.xml">
	<input type="hidden" name="_url"
		value="/cring/jsp/admin/bgUserBindingUserGroup.jsp?groupId=<%=groupId%>">
	<table border='0' align='center' cellspacing='1' cellpadding='0'
		width='100%'>
		<tr>
			<td>
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0" class="table_big">
					<tr>
						<td>
							<table width="100%" border="0" align="center" cellpadding="0"
								cellspacing="0">
								<tr>
									<td width="4" height="4">
										<img src="/cring/image/admin/title_r10_c3.gif" width="4"
											height="4">
									</td>
									<td height="4">
										<img src="/cring/image/admin/title_r12_c4.jpg" width="100%"
											height="4">
									</td>
									<td width="4" height="4">
										<img src="/cring/image/admin/title_r10_c8.gif" width="4"
											height="4">
									</td>
								</tr>
							</table>
							<table width="100%" border="0" align="center" cellpadding="0"
								cellspacing="0">
								<tr>
									<td width="4" background="/cring/image/admin/title_r5_c3.jpg"
										bgcolor="#CCCCCC">
										&nbsp;
									</td>
									<td bgcolor="#EEF7FD">
										<table width="98%" border="0" align="center" cellpadding="0"
											cellspacing="0">
											<tr>
												<td align="center">
													可选用户列表
													<br>
													<pub:link name="selectings" id="selectings" next="false"
														num="1" mutiple="true" selectSize="10" style="test"
														sql="select t2u, user_name
                                                 from (select t2.user_name, t2.user_info_id t2u, t3.user_info_id t3u
                                                         from frame_login t1, sys_user_info t2, sys_user_role t3
                                                        where t1.login_state='A'
                                                          and t1.login_id = t2.login_id
                                                          and t2.user_info_id = t3.user_info_id(+))
                                                where t3u is null and user_name <>'admin' order by user_name"
														event="onDblClick=move_right();" />
												</td>

												<td align="center" width="25%">
													<input type="button" value="追加→" class="button_xy_normal"
														onClick="move('selectings','selecteds');">
													<br>
													<br>
													<input type="button" value="←删除" class="button_xy_normal"
														onClick="move('selecteds','selectings');">
													<br>
													<br>
													<input type="button" value="全选=>" class="button_xy_normal"
														onClick="move_right_all();">
													<br>
													<input type="button" value="<=全删" class="button_xy_normal"
														onClick="move_left_all();">
												</td>

												<td align="center">
													用户组
													<font color="blue">[<%=sysRole.getRoleName()%>]</font>用户
													<br>
													<pub:link name="selecteds" id="selecteds" next="false"
														num="1" mutiple="true" selectSize="10" style="test"
														sql="<%=sql%>" event="onDblClick=move_left();" />
												</td>

												<td height="5"
													background="/cring/image/admin/title_r10_c5.jpg"></td>

											</tr>
										</table>
									</td>
								</tr>
							</table>
							<table width="98%" border="0" align="center" cellpadding="0"
								cellspacing="0">
								<tr>
									<td height="10" valign="top">
										<table width="100%" border="0" align="center" cellpadding="0"
											cellspacing="1">
											<tr>
												<td height="5"
													background="/cring/image/admin/title_r10_c5.jpg"></td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
							<br>
							<table border="0" align="center" cellpadding="0" cellspacing="20">
								<tr>
									<td bgcolor="#EEF7FD">
										<div align="center">
											<input type="submit" class="button_xy_normal" value="保存">
										</div>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<table width="100%" border="0" align="center" cellpadding="0"
					cellspacing="0">
					<tr>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r10_c3.gif" width="4"
								height="4">
						</td>
						<td height="4">
							<img src="/cring/image/admin/title_r12_c4.jpg" width="100%"
								height="4">
						</td>
						<td width="4" height="4">
							<img src="/cring/image/admin/title_r10_c8.gif" width="4"
								height="4">
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<br>
</form>
<br>

